package top.z.orm.handle.osql.chain;

import top.z.orm.core.osql.chain.ToSql;

import java.util.StringJoiner;

import static top.z.orm.core.osql.SqlKeyWord.SPACE;

public abstract class AbstractToSql implements ToSql {

    protected StringJoiner sql = new StringJoiner(SPACE);

    public String toSQL() {
        // Oracle 用 JDBC 不允许有分号
        return toSQL(true);
    }

    public String toSQL(boolean noSemicolon) {
        if (noSemicolon) {
            return sql.toString();
        } else {
            return sql.toString() + ";";
        }
    }
}